home *** CD-ROM | disk | FTP | other *** search
- property pMaxPoint, pMinPoint, pWhichSlider, pDragging, pWidth
- global gCarAttributes, gRacers
-
- on getPropertyDescriptionList me
- list = [:]
- addProp(list, #pWhichSlider, [#comment: "Which Slider?", #format: #symbol, #default: #acceleration, #range: [#brake, #acceleration, #turning]])
- return list
- end
-
- on beginSprite me
- pBeginPoint = sprite(me.spriteNum).loc
- pMaxPoint = sprite(me.spriteNum).loc + point(144, 0)
- pMinPoint = pBeginPoint
- pWidth = pMaxPoint.locH - pMinPoint.locH
- me.loadStats()
- end
-
- on exitFrame me
- if pDragging then
- theLocH = the mouseH
- if theLocH < pMaxPoint.locH then
- if theLocH > pMinPoint.locH then
- me.setLoc(theLocH)
- else
- me.setLoc(pMinPoint.locH)
- end if
- else
- me.setLoc(pMaxPoint.locH)
- end if
- end if
- end
-
- on mouseEnter me
- cursor(260)
- end
-
- on mouseLeave me
- if not pDragging then
- cursor(-1)
- end if
- end
-
- on mouseDown me
- me.grab()
- end
-
- on mouseUp me
- me.release()
- end
-
- on mouseUpOutSide me
- me.release()
- end
-
- on grab me
- cursor(290)
- pDragging = 1
- end
-
- on release me
- pDragging = 0
- cursor(-1)
- end
-
- on setLoc me, theLocH
- sprite(me.spriteNum).locH = theLocH
- thePercent = (theLocH - pMinPoint.locH) / float(pWidth)
- me.setStats(thePercent)
- sendSprite(me.spriteNum - 1, #updateMask, thePercent)
- end
-
- on loadStats me
- theMin = gCarAttributes[pWhichSlider].min
- theMax = gCarAttributes[pWhichSlider].max
- theRange = theMax - theMin
- if pWhichSlider = #brake then
- theValue = gRacers[1].pBrakeGain
- else
- if pWhichSlider = #acceleration then
- theValue = gRacers[1].pAccGain
- else
- if pWhichSlider = #turning then
- theValue = gRacers[1].pTurnData.sensitivity
- end if
- end if
- end if
- thePercent = (theValue - theMin) / theRange
- theLocH = (thePercent * pWidth) + pMinPoint.locH
- me.setLoc(theLocH)
- end
-
- on setStats me, thePercent
- theMin = gCarAttributes[pWhichSlider].min
- theMax = gCarAttributes[pWhichSlider].max
- theRange = theMax - theMin
- theVal = theMin + (theRange * thePercent)
- if pWhichSlider = #brake then
- gRacers[1].pBrakeGain = theVal
- else
- if pWhichSlider = #acceleration then
- gRacers[1].pAccGain = theVal
- gRacers[1].pMaxSpeed = ((gCarAttributes[#speed].max - gCarAttributes[#speed].min) * (1 - thePercent)) + gCarAttributes[#speed].min
- else
- if pWhichSlider = #turning then
- gRacers[1].pTurnData.sensitivity = theVal
- end if
- end if
- end if
- end
-